from PyQt5.QtWidgets import QApplication, QPushButton, QVBoxLayout, QWidget
from PyQt5.QtCore import pyqtSignal
import UI_2


class DataAnalysis(QWidget):
    show_table_selection_signal = pyqtSignal(list)

    def __init__(self):
        super().__init__()
        self.setGeometry(200, 200, 300, 300)
        self.setWindowTitle("开始")
        layout = QVBoxLayout()
        button = QPushButton("打开文件")
        button1 = QPushButton("关闭程序")
        layout.addWidget(button)
        layout.addWidget(button1)
        button.clicked.connect(self.open_file)
        button1.clicked.connect(self.close_program)
        self.setLayout(layout)
        self.show()

    def open_file(self):
        window = UI_2.ChooseWorkBook()
        file_list = window.filelist
        if len(file_list) != 0:
            self.show_table_selection_signal.emit(file_list)

    def quit_window(self):
        self.close()

    def close_program(self):
        QApplication.exit()
